<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/header', TEMPLATE_INCLUDEPATH)) : (include template('public/header', TEMPLATE_INCLUDEPATH));?>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/comhead', TEMPLATE_INCLUDEPATH)) : (include template('public/comhead', TEMPLATE_INCLUDEPATH));?>
<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li  <?php  if($type=='all') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('type'=>all,'status'=>6));?>">全部订单</a></li>
    <li   <?php  if($type=='wait') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('type'=>wait,'status'=>1,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));?>">待支付</a></li>
    <li   <?php  if($type=='ok') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('type'=>ok,'status'=>2,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));?>">已支付</a></li>
    <li   <?php  if($type=='no') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('type'=>no,'status'=>3,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));?>">已取车</a></li>
    <li   <?php  if($type=='finish') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('type'=>finish,'status'=>0,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));?>">已完成</a></li>
    <li   <?php  if($type=='qx') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('type'=>qx,'status'=>4,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));?>">已取消</a></li>
    <li   <?php  if($type=='tk') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('type'=>tk,'status'=>5,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));?>">退款成功</a></li>
</ul>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">退款处理:</div>
    <li   <?php  if($refund=='refund') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('refund'=>refund,'istui'=>1,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));?>">未处理</a></li>
    <li   <?php  if($refund=='refundno') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('refund'=>refundno,'istui'=>3,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));?>">退款失败</a></li>
    <span class="ygxian"></span>
    <div class="ygdangq">退押金处理:</div>
    <li   <?php  if($deposit=='refund') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('deposit'=>refund,'isdeposit'=>1,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));?>">未处理</a></li>
    <li   <?php  if($deposit=='refundyes') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('deposit'=>refundyes,'isdeposit'=>2,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));?>">退押金成功</a></li>
    <li   <?php  if($deposit=='refundno') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('deposit'=>refundno,'isdeposit'=>3,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));?>">退押金失败</a></li>
    <span class="ygxian"></span>
    <div class="ygdangq">删除处理:</div>
    <li   <?php  if($del=='del') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('order',array('del'=>del,'isdel'=>0,'refund'=>$refund,'istui'=>$istui,'type'=>$type,'status'=>$status,'deposit'=>$deposit,'isdeposit'=>$isdeposit));?>">已删除</a></li>
</ul>
<div class="row ygrow">
    <div class="col-lg-12">
        <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="order" />
            <div class="input-group">
                <input type="text" name="keywords" class="form-control" placeholder="请输入订单号">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
        </div>
    </div>
</div>
<div class="row ygrow">
    <div class="col-lg-12">
        <a data-toggle="modal" data-target="#myModalsss"><button class="btn btn-xs storeblue">导出客户租车信息</button></a>
        <div class="modal fade" id="myModalsss" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">客户租车信息导出</h4>
                  </div>
                  <form action="" method="get" >
                      <input type="hidden" name="c" value="site" />
                      <input type="hidden" name="a" value="entry" />
                      <input type="hidden" name="m" value="yzzc_sun" />
                      <input type="hidden" name="do" value="order" />
                      <input type="hidden" name="status" value="<?php  echo $status;?>" />
                      <input type="hidden" name="op" value="exportorder" />
                      <div class="modal-body" style="font-size: 20px">
                            <span>
                            <?php  if($status ==1) { ?>即将导出待支付订单？
                            <?php  } else if($status == 2 ) { ?>即将导出已支付订单？
                            <?php  } else if($status == 3 ) { ?>即将导出已取车订单？
                            <?php  } else if($status == 4 ) { ?>即将导出已取消订单？
                            <?php  } else if($status == 0 ) { ?>即将导出已完成订单？
                            <?php  } else if($status == 5 ) { ?>即将导出已退款订单？
                            <?php  } else if($status == 6 ) { ?>即将导出所有订单？
                            <?php  } else { ?>即将导出所有订单？
                            <?php  } ?>
                            </span>
                      </div>

                      <div class="modal-footer">
                          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                          <input type="submit" class="btn btn-info" name="submit" value="确定"/>
                      </div>
                      <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
                  </form>
                </div>
              </div>
          </div>
        <!-- <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="order" />
            <input type="hidden" name="op" value="exportorder" />
            <div class="input-group">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="导出客户租车信息"/>
                </span>
            </div>
            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
        </div> -->
    </div>
</div>
<div class="main ">
    <div class="panel panel-default">
        <!--<div class="panel-body ygbtn">-->
            <!--<div class="btn ygshouqian2" id="allselect">批量删除</div>-->
            <!--<div class="btn ygyouhui2" id="allpass">批量通过</div>-->
            <!--<div class="btn storegrey2" id="allrefuse">批量拒绝</div>-->
        <!--</div>-->
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            订单列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <!--<td class="store_td1 col-md-1" style="text-align: center;">-->
                            <!--<input type="checkbox" class="allcheck" />-->
                            <!--<span class="store_inp">全选</span>-->
                        <!--</td>-->
                        <td class="store_td1 col-md-1">订单号</td>
                        <td class="col-md-1">订单类型</td>
                        <td class="col-md-1">门店名称（门店id）</td>
                        <td class="col-md-1">车辆名称（车辆id）（车牌号）</td>
                        <td class="col-md-1">租车时间</td>
                        <td class="col-md-1">总天数</td>
                        <td class="col-md-1">微信名（用户id）</td>

                        <!--<td class="col-md-1">商户订单号</td>-->
                        <td class="col-md-1">定金 / 续租费</td>
                        <td class="col-md-1">取车名称 / 手机</td>
                        <td class="col-md-1">订单状态</td>
                        <td class="col-md-2">操作</td>
                    </tr>
                    <?php  if(is_array($list)) { foreach($list as $key => $item) { ?>
                    <tr class="yg5_tr2">
                        <!--<td>-->
                            <!--<input type="checkbox" name="test" value="<?php  echo $item['id'];?>">-->
                        <!--</td>-->
                        <td><?php  echo $item['ordernum'];?></td>
                        <?php  if($item['type']==1) { ?>
                        <td>短租订单</td>
                        <?php  } else { ?>
                        <td>长租订单</td>
                        <?php  } ?>
                        <td><?php  echo $item['shopname'];?>(<?php  echo $item['start_shop'];?>)</td>
                        <td><?php  echo $item['carname'];?>(<?php  echo $item['cid'];?>)(<?php  echo $item['carnum'];?>)</td>
                        <td><?php  echo $item['start_time'];?> <br>~<br> <?php  echo $item['end_time'];?></td>
                        <td><?php  echo $item['day'];?></td>
                        <td><?php  echo $item['nickname'];?> (<?php  echo $item['uid'];?>)</td>
                        <td><?php  echo $item['prepay_money'];?> / <?php  echo $item['xzmoney'];?></td>

                        <td><?php  echo $item['username'];?> / <?php  echo $item['tel'];?></td>

                        <td>
                        <?php  if($item['display']==1) { ?>
                            <?php  if($item['status']==1) { ?>
                            <!-- <td> -->
                                <span class="label storered">待支付</span>
                            <!-- </td > -->
                            <?php  } else if($item['status']==2) { ?>
                            <!-- <td > -->
                                <span class="label storeblue">已支付</span>
                            <!-- </td> -->
                            <?php  } else if($item['status']==3) { ?>
                            <!-- <td> -->
                                <span class="label storegrey">已取车</span>
                            <!-- </td> -->
                            <?php  } else if($item['status']==4) { ?>
                            <!-- <td> -->
                                <span class="label storegrey">已取消</span>
                            <!-- </td> -->
                            <?php  } else if($item['status']==0) { ?>
                            
                                <span class="label storegrey">已完成</span>
                            
                            <?php  } ?>
                            <?php  if($item['istui']==2) { ?>
                                  <span class="label storegrey">退款成功</span>
                            <?php  } else if($item['istui']==3) { ?>
                                  <span class="label storeblue">退款失败</span>
                            <?php  } else if($item['istui']==1) { ?>
                                  <span class="label storeblue">退款申请中</span>
                            <?php  } ?>
                            <?php  if($item['isdeposit']==2) { ?>
                                  <span class="label storegrey">退押金成功</span>
                            <?php  } else if($item['isdeposit']==3) { ?>
                                  <span class="label storeblue">退押金失败</span>
                            <?php  } else if($item['isdeposit']==1) { ?>
                                  <span class="label storeblue">退押金申请中</span>
                            <?php  } ?>
                            <?php  if($item['iszx']==1) { ?>
                                  <span class="label storegrey">已续租</span>
                            <?php  } ?>
                        <?php  } else { ?>
                              <span class="label storegrey">已删除</span>
                    
                        <?php  } ?>
                        </td>
                        <td>
                            <?php  if($item['status']==1) { ?>
                            <a href="<?php  echo $this->createWebUrl('order',array('op'=>'cancel','id'=>$item['id']));?>"><button class="btn storeblue btn-xs">取消</button></a>
                            <a data-toggle="modal" data-target="#myModalssssss"><button class="btn btn-xs storeblue">修改支付金额</button></a>
                            <div class="modal fade" id="myModalssssss" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                              <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">修改支付金额</h4>
                                      </div>
                                      <form action="" method="get" >
                                          <input type="hidden" name="c" value="site" />
                                          <input type="hidden" name="a" value="entry" />
                                          <input type="hidden" name="m" value="yzzc_sun" />
                                          <input type="hidden" name="do" value="order" />
                                          <input type="hidden" name="op" value="update" />
                                          <input type="hidden" name="id" value="<?php  echo $item['id'];?>" />
                                          <div class="modal-body" style="font-size: 20px">
                                                <label class="col-xs-12 col-sm-3 col-md-2 control-label">支付金额</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="prepay_money" class="form-control" value="<?php  echo $item['prepay_money'];?>" />
                                                </div>
                                          </div>

                                          <div class="modal-footer">
                                              <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                              <input type="submit" class="btn btn-info" name="submit" value="确定"/>
                                          </div>
                                          <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
                                      </form>
                                    </div>
                                  </div>
                              </div>
                            <?php  } ?>
                            <?php  if($item['status']==3) { ?>
                            <a href="<?php  echo $this->createWebUrl('order',array('op'=>'return','id'=>$item['id']));?>"><button class="btn storeblue btn-xs">还车</button></a>
                            <?php  } ?>
                            <?php  if($item['ispl']==1) { ?>
                            <a href="<?php  echo $this->createWebUrl('orderpj',array('id'=>$item['id']));?>"><button class="btn storeblue btn-xs">查看验车评价</button></a>
                            <?php  } ?>
                            <a href="<?php  echo $this->createWebUrl('orderjsy',array('id'=>$item['id']));?>"><button class="btn storeblue btn-xs">订单详情</button></a>

                            <?php  if($item['istui']==1) { ?>
                                <a href="<?php  echo $this->createWebUrl('order', array('op'=>refund,'id'=>$item['id'],'refund'=>2))?>"><button class="btn btn-xs storeblue">通过退款申请</button></a>
                                <a href="<?php  echo $this->createWebUrl('order', array('op'=>refund,'id'=>$item['id'],'refund'=>3))?>"><button class="btn btn-xs storeblue">拒绝退款申请</button></a>
                            <?php  } ?>
                            <?php  if($item['isdeposit']==1) { ?>
                                <a href="<?php  echo $this->createWebUrl('order', array('op'=>refunddeposit,'id'=>$item['id'],'refund'=>2))?>"><button class="btn btn-xs storeblue">通过退押金申请</button></a>
                                <a href="<?php  echo $this->createWebUrl('order', array('op'=>refunddeposit,'id'=>$item['id'],'refund'=>3))?>"><button class="btn btn-xs storeblue">拒绝退押金申请</button></a>
                            <?php  } ?>
                            <?php  if($item['status'] !=2 && $item['status']!=3 &&$item['display']==1) { ?>
                            <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModal<?php  echo $item['id'];?>">
                                <span class="fa fa-trash-o"></span>
                                <span class="bianji">删除
                                    <span class="arrowdown"></span>
                                </span>
                            </a>
                            <?php  } ?>
                        </td>
                    </tr>
                    <div class="modal fade" id="myModal<?php  echo $item['id'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                                </div>
                                <div class="modal-body" style="font-size: 20px">
                                    确定删除么？
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <a href="<?php  echo $this->createWebUrl('order', array('op' => 'delete', 'oid' => $item['id']))?>" type="button" class="btn btn-info" >确定</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php  } } ?>
                    <?php  if(empty($list)) { ?>
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无订单信息
                        </td>
                    </tr>
                    <?php  } ?>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="text-right we7-margin-top">
    <?php  echo $pager;?>
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-2").show();
        $("#yframe-2").addClass("wyactive");
        // ———————————————批量删除———————————————
        $("#allselect").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的商品!');
                return false;
            }else if(confirm("确认要删除此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });

                $.ajax({
                    type:"post",
                    url:"<?php  echo $_W['siteroot'];?>/app/index.php?i=<?php  echo $_W['uniacid'];?>&c=entry&do=order&op=delete&m=yzzc_sun",
                    dataType:"text",
                    data:{oid:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })

            }
        });

        // ———————————————批量通过———————————————
        $("#allpass").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要通过的商品!');
                return false;
            }else if(confirm("确认要通过此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"<?php  echo $_W['siteroot'];?>/app/index.php?i=<?php  echo $_W['uniacid'];?>&c=entry&do=Adoptorder&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        // ———————————————批量拒绝———————————————
        $("#allrefuse").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要拒绝的商品!');
                return false;
            }else if(confirm("确认要拒绝此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"<?php  echo $_W['siteroot'];?>/app/index.php?i=<?php  echo $_W['uniacid'];?>&c=entry&do=Rejectorder&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        $(".allcheck").on('click',function(){
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked",checked);
        });
    })
</script>